import numpy as np
from sklearn.model_selection import train_test_split
from sklearn.svm import SVC

def main():
    # 数据准备
    # Integr_data
    X = np.array([
        [0, 0, 0, 0, 0, 0],  
        [1, 0, 1, 0, 0, 0],  
        [1, 0, 0, 0, 0, 0],  
        [0, 0, 1, 0, 0, 0],  
        [2, 0, 0, 0, 0, 0],  
        [0, 1, 0, 0, 1, 1],  
        [1, 1, 0, 1, 1, 1],  
        [1, 1, 0, 0, 1, 0],  
        [1, 1, 1, 1, 1, 0],  
        [0, 2, 2, 0, 2, 1],  
        [2, 2, 2, 2, 2, 0],  
        [2, 0, 0, 2, 2, 1],  
        [0, 1, 0, 1, 0, 0],  
        [2, 1, 1, 1, 0, 0],  
        [1, 1, 0, 0, 1, 1],  
        [2, 0, 0, 2, 2, 0],  
        [0, 0, 1, 1, 1, 0]   
    ])
    y = np.array([1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0])
    # feature_names = ['色泽', '根蒂', '敲声', '纹理', '脐部', '触感']
    X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

    # 支持向量机
    svm_model = SVC(kernel='linear', C=0.5)
    svm_model.fit(X_train, y_train)
    acc = svm_model.score(X_test, y_test)
    print("准确率：", acc)
    print(f"支持向量索引：{svm_model.support_}")
    print(f"支持向量个数：{svm_model.n_support_}")


if __name__ == "__main__":
    main()